home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Magazine / SoundLab / Studio16add / sources / S16MakePermanent.asm < prev   
Encoding:
Assembly Source File  |  1997-12-10  |  7.6 KB  |  394 lines

  1. *>b:S16MakePermanent
  2.  
  3.     *«««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*
  4.     *   Copyright © 1997 by Kenneth "Kenny" Nilsen.  E-Mail: kenny@bgnett.no              *
  5.     *   Source viewed in 800x600 with mallx.font (11) in CED                      *
  6.     *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  7.     *
  8.     *   Name
  9.     *    S16MakePermanent
  10.     *
  11.     *   Function
  12.     *    Permanent edits in Studio 16 files if any
  13.     *
  14.     *   Inputs
  15.     *    <file>
  16.     *
  17.     *   Notes
  18.     *    
  19.     *   Bugs
  20.     *    
  21.     *   Created    : 12.11.97
  22.     *   Changes    : 12.11.97, 13.11.97, 26.11.97, 27.11.97
  23.     *««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««*
  24.  
  25.  
  26. ;StartSkip    SET    1
  27. ;DODUMP        SET    1
  28.  
  29.  
  30.         Incdir    inc:
  31.  
  32.         include    lvo/exec_lib.i
  33.         include    lvo/dos_lib.i
  34.  
  35.         include    digital.macs
  36.         include    digital.i
  37.         include    libraries/studio16file.i
  38.  
  39.         include    dos/dos.i
  40.         include    exec/types.i
  41.  
  42.         include    startup.asm
  43.  
  44.         Incdir    ""
  45.  
  46.         dc.b    "$VER: S16MakePermanent 1.1 (27.11.97)",10
  47.         dc.b    "Copyright © 1997 Digital Surface. All rights reserved. ",0
  48.         even
  49. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  50. Dump    macro
  51.     move.l    #5,Warn
  52.     move.l    #\1,d1
  53.     bra    Print
  54.     endm
  55.  
  56. Buffer    =    1024*400+S16S_SIZEOF
  57. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  58. Init        DefLib    dos,37
  59.         DefEnd
  60.  
  61. Start    LibBase    dos
  62.  
  63.     NextArg
  64.     beq    About
  65.     move.l    d0,a0
  66.     cmp.b    #'?',(a0)
  67.     beq    About
  68.  
  69.     lea    IFile(pc),a1
  70. .copy    move.b    (a0)+,(a1)+
  71.     bne.b    .copy
  72.  
  73. ; alloc memory
  74.  
  75.     LibBase    exec
  76.     move.l    #Buffer,d0
  77.     move.l    #$10001,d1
  78.     Call    AllocMem
  79.     move.l    d0,Mem
  80.     beq    ErrorMem
  81.  
  82.     add.l    #Buffer-S16S_sizeof,d0
  83.     move.l    d0,Header
  84.  
  85. *------------------------------------------------------------------------------------------------------------*
  86. ; open file and check it
  87.  
  88.     LibBase    dos
  89.  
  90.     move.l    #IFile,d1
  91.     move.l    #MODE_OLDFILE,d2
  92.     Call    Open
  93.     move.l    d0,IHan
  94.     beq    ErrorOpenI
  95.  
  96.     move.l    d0,d1
  97.     move.l    Mem(pc),d2
  98.     move.l    #S16S_SIZEOF,d3
  99.     Call    Read
  100.     cmp.l    #S16S_SIZEOF,d0
  101.     bne    ErrorRead
  102.  
  103. ; check header
  104.  
  105.     move.l    Mem(pc),a0
  106.     cmp.l    #'KWK3',(a0)
  107.     bne    ErrorType
  108.  
  109. ; equal size ?
  110.  
  111.     move.l    S16S_REALSIZE(a0),d0
  112.     move.l    S16S_EDITSIZE(a0),d1
  113.     cmp.l    d0,d1
  114.     bne    .notEQ
  115.  
  116. ; count SampleClips
  117.  
  118.     lea    S16S_EDITLIST(a0),a1    ;Show main clip as well
  119.     moveq    #0,d0            ;SampleClip counter
  120.     moveq    #MAXSAMPLECLIPS-1,d1    ;list tracker counter
  121. .countS    move.l    (a1)+,d2        ;_START
  122.     move.l    (a1)+,d3        ;_END
  123.     beq    .smpEnd
  124.     addq.l    #1,d0            ;we had one, add one to counter
  125.     dbra    d1,.countS
  126.  
  127. .smpEnd    cmp.l    #1,d0
  128.     beq    ErrorEdit
  129.  
  130. ; create temp file name
  131.  
  132. .notEQ    lea    IFile(pc),a0
  133.     lea    OFile(pc),a1
  134. .copyF    move.b    (a0)+,(a1)+
  135.     bne.b    .copyF
  136.     lea    -1(a1),a1
  137.     lea    Ext(pc),a0
  138. .copyX    move.b    (a0)+,(a1)+
  139.     bne.b    .copyX
  140.  
  141. ; try open temp file
  142.  
  143.     move.l    #OFile,d1
  144.     move.l    #MODE_NEWFILE,d2
  145.     Call    Open
  146.     move.l    d0,OHan
  147.     beq    ErrorOpenO
  148.  
  149. ; copy header info
  150.  
  151.     move.l    Mem(pc),a0
  152.     move.l    Header(pc),a1
  153.     move.l    #S16S_res/2,d0
  154. .copyH1    move.w    (a0)+,(a1)+
  155.     subq.l    #1,d0
  156.     bne.b    .copyH1
  157.  
  158. ; copy region list
  159.  
  160.     move.l    Mem(pc),a0
  161.     move.l    Header(pc),a1
  162.     lea    S16S_REGIONLIST(a0),a0
  163.     lea    S16S_REGIONLIST(a1),a1
  164.     move.l    #MAXREGIONS*S16R_SIZEOF/4,d0
  165. .copyR    move.l    (a0)+,(a1)+
  166.     subq.l    #1,d0
  167.     bne.b    .copyR
  168.  
  169.     move.l    Mem(pc),a0
  170.     move.l    Header(pc),a1
  171.  
  172.     move.l    S16S_EDITSIZE(a0),d0
  173.     move.l    d0,EditSize
  174.     move.l    d0,S16S_REALSIZE(a1)
  175.     move.l    d0,S16S_EDITSIZE(a1)
  176.     subq.l    #1,d0
  177.     move.l    d0,S16S_END(a1)
  178.     move.l    #S16FILTERINIT,S16S_FILTER(a1)
  179.  
  180.     move.l    OHan(pc),d1
  181.     move.l    Header(pc),d2
  182.     move.l    #S16S_SIZEOF,d3
  183.     Call    Write
  184.     cmp.l    #-1,d0
  185.     beq    ErrorWrite
  186. *------------------------------------------------------------------------------------------------------------*
  187. ; Start MAIN converting
  188.  
  189. Main    move.l    #StartTxt,d1
  190.     Call    PutStr
  191.  
  192.     move.l    Mem(pc),a5
  193.     lea    S16S_EDITLIST(a5),a5
  194.  
  195. .loop    move.l    (a5)+,d6        ;start
  196.     move.l    (a5)+,d7        ;end
  197.     beq    .done
  198.     addq.l    #1,d7            ;add 1
  199.  
  200.     move.l    d6,Buff
  201.     move.l    d7,Buff+4
  202.  
  203.     LibBase    exec
  204.     lea    String(pc),a0
  205.     lea    Buff(pc),a1
  206.     lea    Proc(pc),a2
  207.     lea    Buff+8(pc),a3
  208.     Call    RawDoFmt
  209.  
  210.     LibBase    dos
  211.     move.l    a3,d1
  212.     Call    PutStr
  213.  
  214.     sub.l    d6,d7            ;difference=size of buffer
  215.     move.l    d7,Buff
  216.     add.l    d7,Total        ;update total counter
  217.     asl.l    #1,d7            ;*2 for bytesize - D7=size of part
  218.     asl.l    #1,d6            ;startpos.
  219.  
  220.     LibBase    exec
  221.     lea    String2(pc),a0
  222.     lea    Buff(pc),a1
  223.     lea    Proc(pc),a2
  224.     lea    Buff+4(pc),a3
  225.     Call    RawDoFmt
  226.  
  227.     LibBase    dos
  228.     move.l    a3,d1
  229.     Call    PutStr
  230.  
  231. ;seek to START
  232.  
  233.     add.l    #S16S_SIZEOF,d6
  234.  
  235.     move.l    IHan(pc),d1
  236.     move.l    d6,d2
  237.     move.l    #OFFSET_BEGINNING,d3
  238.     Call    Seek
  239.     cmp.l    #-1,d0
  240.     beq    ErrorSeek
  241.  
  242. ; read part, buffered
  243.  
  244.     moveq    #-1,d5
  245. .copy    tst.b    d5
  246.     beq    .loop
  247.  
  248.     move.l    IHan(pc),d1
  249.     move.l    Mem(pc),d2
  250.     add.l    #S16S_SIZEOF,d2
  251.     move.l    d7,d3
  252.     cmp.l    #Buffer-S16S_SIZEOF,d3
  253.     ble    .sizeOk
  254.     move.l    #Buffer-S16S_SIZEOF,d3
  255. .sizeOk    move.l    d3,d4
  256.     Call    Read
  257.  
  258.     move.l    d0,d3
  259.     beq    .done
  260.     cmp.l    d4,d3
  261.     beq    .readOk
  262.     cmp.l    #-1,d3
  263.     beq    ErrorRead
  264.  
  265.     moveq    #0,d5
  266.  
  267. .readOk    move.l    OHan(pc),d1
  268.     move.l    Mem(pc),d2
  269.     add.l    #S16S_SIZEOF,d2
  270.     Call    Write
  271.  
  272.     cmp.l    d3,d0
  273.     bne    ErrorWrite
  274.     cmp.l    #-1,d0
  275.     beq    ErrorWrite
  276.     sub.l    d3,d7
  277.     bne    .copy
  278.     bra    .loop
  279.  
  280. .done    LibBase    exec
  281.  
  282.     move.l    #EditOk,EditStatus
  283.     move.l    Total(pc),d0
  284.     move.l    EditSize(pc),d1
  285.     cmp.l    d0,d1
  286.     beq    .EdOk
  287.     move.l    #EditErr,EditStatus
  288.  
  289. .EdOk    lea    String3(pc),a0
  290.     lea    EditSize(pc),a1
  291.     lea    Proc(pc),a2
  292.     lea    Buff(pc),a3
  293.     Call    RawDoFmt
  294.  
  295.     LibBase    dos
  296.     move.l    a3,d1
  297.     Call    PutStr
  298.  
  299.     move.l    IHan(pc),d1
  300.     Call    Close
  301.     clr.l    IHan
  302.     move.l    OHan(pc),d1
  303.     Call    Close
  304.     clr.l    OHan
  305.  
  306.     move.l    #Ifile,d1
  307.     Call    DeleteFile
  308.     tst.l    d0
  309.     beq    ErrorDel
  310.  
  311.     move.l    #OFile,d1
  312.     move.l    #IFile,d2
  313.     Call    Rename
  314.     tst.l    d0
  315.     beq    ErrorRename
  316.  
  317. *------------------------------------------------------------------------------------------------------------*
  318. Close    LibBase    exec
  319.     move.l    Mem(pc),d0
  320.     beq    .noMem
  321.     move.l    d0,a1
  322.     move.l    #Buffer,d0
  323.     Call    FreeMem
  324.  
  325. .noMem    LibBase    dos
  326.     move.l    IHan(pc),d1
  327.     beq    .noI
  328.     Call    Close
  329.  
  330. .noI    move.l    OHan(pc),d1
  331.     beq    .noO
  332.     Call    Close
  333.  
  334. .noO    move.l    Warn(pc),d0
  335.     rts
  336. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  337. Proc    move.b    d0,(a3)+
  338.     rts
  339.  
  340. ErrorMem    Dump    ErrMem
  341. ErrorOpenI    Dump    ErrOpenI
  342. ErrorOpenO    Dump    ErrOpenO
  343. ErrorRead    Dump    ErrRead
  344. ErrorWrite    Dump    ErrWrite
  345. ErrorType    Dump    ErrType
  346. ErrorEdit    Dump    ErrEdit
  347. ErrorSeek    Dump    ErrSeek
  348. ErrorDel    Dump    ErrDel
  349. ErrorRename    Dump    ErrRename
  350.  
  351. About        move.l    #AboutTxt,d1
  352.  
  353. Print        LibBase    dos
  354.         Call    PutStr
  355.         bra    Close
  356. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  357. Warn        dc.l    0
  358. IHan        dc.l    0
  359. OHan        dc.l    0
  360. Mem        dc.l    0
  361. Header        dc.l    0
  362. EditSize    dc.l    0
  363. Total        dc.l    0
  364. EditStatus    dc.l    0
  365.  
  366. Buff        dcb.b    70,0
  367. IFile        dcb.b    300,0
  368. OFile        dcb.b    300,0
  369. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  370. ErrMem        dc.b    "Out of memory! Need 400kb..",10,0
  371. ErrOpenI    dc.b    "Couldn't open input file!",10,0
  372. ErrOpenO    dc.b    "Couldn't open temp file for write!",10,0
  373. ErrRead        dc.b    "Error reading file!",10,0
  374. ErrWrite    dc.b    "Error writing file!",10,0
  375. ErrType        dc.b    "This is not a Studio 16 3.0 file!",10,0
  376. ErrEdit        dc.b    "File is already made permanent!",10,0
  377. ErrSeek        dc.b    "Error Seek()'ing file while permanenting!",10,0
  378. ErrDel        dc.b    "Couldn't remove temp file!",10,0
  379. ErrRename    dc.b    "Couldn't rename temp file to original!",10,0
  380.  
  381. StartTxt    dc.b    10,"EDIT TABLE:",10
  382.         dc.b    "-------------------------------------------------------",10,0
  383. String        dc.b    "Start: %10.ld  Stop: %10.ld",0
  384. String2        dc.b    "  Size: %10.ld",10,0
  385. String3        dc.b    10,"Original edit size: %ld  New size: %ld (%s)",10,10,0
  386.  
  387. Ext        dc.b    ".edit",0
  388. EditOk        dc.b    "OK",0
  389. EditErr        dc.b    "ERROR",0
  390.  
  391. AboutTxt    dc.b    10,27,"[1mS16MakePermanent",27,"[0m 1.1 by Kenneth 'Kenny' Nilsen (kenny@bgnett.no)",10,10
  392.         dc.b    "    USAGE: S16MakePermanent <Studio 16 file>",10,10,0
  393. *»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»*
  394.